<?php
/**
 * Created by PhpStorm.
 * User: fengzi
 * Date: 2019/5/29
 * Time: 17:18
 */

namespace app\vehicle\model;
use think\Model;

class Order extends Model
{
    public function getUseTimeAttr($value){
        return date('Y-m-d H:i',$value);
    }
    public function getBackTimeAttr($value){
        if($value){
            return date('Y-m-d H:i',$value);
        }else{
            return '';
        }
    }
    public function getStatusAttr($value)
    {
        //订单状态  0生成订单成1订单已匹配2订单已确认3订单已付款4订单已取消5订单申请退款6订单已退款7订单已完成
        $status = [0=>'待確認',1=>'進行中',2=>'已完成',3=>'已取消',4=>'已取消',5=>'申请退款',6=>'已退款',7=>'待评价',8=>'已完成'];
        return $status[$value];
    }
    public function price(){
        return $this->hasOne('order_price','order_id','id')->bind('pay_price');
    }

    public function brand(){
        return $this->hasOne('bus_brand','id','brand_id')->bind([
            'brand_name'=>'name'
        ]);
    }
}